package org.lewis.service.impl;

import java.util.List;
import org.hibernate.SessionFactory;
import org.lewis.core.domain.User;
import org.lewis.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class UserServiceImpl implements UserService {
	
	@Autowired
	SessionFactory sessionFactory;
	

	public void saveUser(User user) {
		sessionFactory.getCurrentSession().save(user);
	}

	@SuppressWarnings("unchecked")
	public List<User> getAllUsers() {
		return sessionFactory.getCurrentSession().createQuery("select u from User u").list().subList(200, 300);
	}


}
